<template>
  <div>
    <input class="ipt" type="text" v-model="value" @keydown.enter="add" />
  </div>
</template>

<script>
export default {
  data() {
    return {
      value: "",
    };
  },
  methods: {
    add() {
      if (this.value == "") {
        alert("输入不能为空");
        return;
      }
      this.$emit("add", this.value);
      this.value = "";
    },
  },
};
</script>

<style scoped>
.ipt {
  width: 100%;
  height: 30px;
  border: 1px solid cyan;
  outline: none;
}
</style>
